# 题目五 - 2 : 使用FAST检测角点
import cv2 as cv
import numpy as np

# 读取图像以及90度旋转图像
filename = r"D:\AI\Picture\left03.jpg"
img1 = cv.imread(filename)
img2 = np.rot90(img1)

# 转换为灰度图
gray1 = cv.cvtColor(img1, cv.COLOR_BGR2GRAY)
gray2 = cv.cvtColor(img2, cv.COLOR_BGR2GRAY)
# 创建fast检测算子,检测
fast = cv.FastFeatureDetector_create(50)
k1 = fast.detect(gray1, None)
k2 = fast.detect(gray2, None)
# 提取描述子
br = cv.BRISK_create()
k1, d1 = br.compute(gray1, k1)
k2, d2 = br.compute(gray2, k2)

# 创建 BFMatcher 对象
bf = cv.BFMatcher(cv.NORM_L2)
# 根据描述子匹配特征点.
matches = bf.match(d1, d2)
# 画出匹配点
img3 = cv.drawMatches(img1, k1, img2, k2, matches[:100], None, flags=2)
cv.imshow("FAST", img3)

cv.waitKey()
cv.destroyAllWindows()




















